import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { AuthMiddleware } from './middleware/Auth.middleware'
import { ValidationPipe } from '@nestjs/common';
import { from } from 'rxjs';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableCors()
  app.useGlobalPipes(new ValidationPipe())
  const options = new DocumentBuilder()
    .setTitle('NestJs 接口(小城在线的商城项目)')
    .setDescription(`<h3>前端</h3> 
                        后台管理系统 vue + element ui + axios 
                        地址: <a href="http://www.xcio.cn/shopadmin" target="_blank">http://www.xcio.cn/shopadmin</a>
                    <h3>后端</h3> 
                        nest + typegoose + mongodb + swagger
                        接口文档地址: <a href="http://www.shubuzuo.top/api-docs">http://www.shubuzuo.top/api-docs</a>
                        系统文档地址: <a href="#">暂无</a>`)
    .addBearerAuth()
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api-docs', app, document);

  await app.listen(5000);
}
bootstrap();
